/*
 * Filename    : State_Game_Over.java
 * Projectname : RamaShinta
 * Date        : Nov 25, 2012 , 10:40:38 AM 
 * 
 */

package com.amikomgamedev.ramashinta.state;

import org.andengine.entity.scene.ITouchArea;
import org.andengine.input.touch.TouchEvent;

import com.amikomgamedev.ramashinta.ServerData;
import com.amikomgamedev.ramashinta.Utils;

import android.view.KeyEvent;

public class State_Game_Over extends State_Activity
{
	protected void create_State_Game_Over()
	{
		graphic.attachStateLose();
		text.attachYouLose();
	}
	
	
	@Override
	public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX,
			float pTouchAreaLocalY)
	{
		if (State_Menu_Current == STATE_GAME_OVER)
		{
			 if (pTouchArea.equals(graphic.spr_Btn_Try_Win))
			{
				for(int i=0;i<ServerData.LEVEL11;i++){
				if(ServerData.getSelectedLevel()==i){
					ServerData.setSelectedLevel(i);
					ServerData.setLevelSelection(ServerData.LEVEL_HUTAN);
					detachLoseState();
					switchState(STATE_GAME_PLAY);
					
				}
				}
			}
		
		}

		return super.onAreaTouched(pSceneTouchEvent, pTouchArea, pTouchAreaLocalX, pTouchAreaLocalY);
	}
	
	private void detachLoseState()
	{
		mEngine.runOnUpdateThread(new Runnable()
		{

			@Override
			public void run()
			{
				// TODO Auto-generated method stub
					text.detachYouLose();
					graphic.detachStateLose();
			}
		});
	}

}
